package com.lxq.test2109.main02;

import java.util.Scanner;

public class Main01 {
    static int N = 500010;
    static int[] a = new int[N] , b = new int[N];

    public static void main(String[] args)
    {
        int n;

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();

        for(int i = 1; i <= n; i ++ )
        {
            a[i] = sc.nextInt();
            if(a[i] > a[i - 1])
            {
                b[a[i - 1]] ++;
                b[a[i]] --;
            }
        }
        int ans = 0, t = 0;
        for(int i = 0;i < N;i ++ )
        {
            t += b[i];
            ans = Math.max(ans, t);
        }
        System.out.println(ans);
    }
}
